home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Popular Request
/
By Popular Request (Arsenal Computer)(SysOptics Distribution System).ISO
/
amiga3
/
nwgccstr.lha
/
source.lha
/
startup
/
motorola.s
< prev
next >
Wrap
Text File
|
1994-03-13
|
3KB
|
101 lines
#if !defined(CRT0) && !defined(BCRT0) && !defined(RCRT0)
#define CRT0
#endif
#ifdef CRT0
; normal (large data model) startup code
#endif
#ifdef BCRT0
; base relative (short data model) startup code
#endif
#ifdef RCRT0
; resident (short data model) startup code
#endif
SECTION text,CODE
even
PUBLIC ___amain
PUBLIC ___aexit
#ifndef RCRT0
PUBLIC _geta4
#endif
movem.l d1-d7/a0-a6,-(a7) ; push registers
#ifdef BCRT0
jsr _geta4 ; set global data segment pointer
#endif
#ifdef RCRT0
movea.l 4,a6 ; get SysBase ->a6
movea.l a0,a2 ; store argument ->a2
move.l #___data_size,d2 ;
addi.l #___bss_size,d2 ; global data segment size ->d2
move.l d2,d0 ; size
moveq.l #0,d1 ; MEMF_ANY
jsr -198(a6) ; AllocMem
movea.l d0,a4 ; new global data segment ->a4
bne.b gotit ; yes ?
moveq.l #20,d0 ; oh, dear
bra.b error ;
gotit: ;
lea.l ___a4_init,a3 ; old global data segment pointer
suba.w #32766,a3 ; old global data segment ->a3
move.l d2,d0 ; size
movea.l a3,a0 ; old
movea.l a4,a1 ; new
jsr -624(a6) ; CopyMem
move.l a3,d0 ;
sub.l a4,d0 ; old-new ->d0
movea.l #___datadata_relocs,a0 ; pointer relocation table ->a0
move.l (a0)+,d1 ; number of pointers ->d1
beq.b loopend ; none ?
loop: ;
movea.l (a0)+,a1 ; get offset of next pointer
sub.l d0,0(a1,a4.l) ; and fix it
subq.l #1,d1 ;
bne.b loop ; ready ?
loopend: ;
move.l a4,-(a7) ; push memory address
move.l d2,-(a7) ; and size
adda.w #32766,a4 ; get new global data segment pointer
movea.l a2,a0 ; remember argument
#endif
#ifdef CRT0
move.l a7,stackpointer ; store stackpointer
#else
move.l a7,-32766(a4) ; store stackpointer
#endif
move.l a0,-(a7) ; push Argument
jsr ___amain ; call __amain(), does not return
___aexit:
#ifdef RCRT0
move.l 4(a7),d2 ; remember returncode
#else
move.l 4(a7),d0 ; get returncode
#endif
#ifdef CRT0
movea.l stackpointer,a7 ; set stackpointer
#else
movea.l -32766(a4),a7 ; set stackpointer
#endif
#ifdef RCRT0
movea.l 4,a6 ; get SysBase
move.l (a7)+,d0 ; pop memory size
movea.l (a7)+,a1 ; and address
jsr -210(a6) ; FreeMem()
move.l d2,d0 ; get returncode
error: ;
#endif
movem.l (a7)+,d1-d7/a0-a6 ; pop registers
#ifdef CRT0
_geta4: ;
#endif
rts ;
#ifdef BCRT0
_geta4: ; Set global-data segment pointer
lea.l ___a4_init,a4 ;
rts ;
#endif
SECTION readwrite,DATA
even
stackpointer:
dc.l 0